#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    string s;
    cin>>s;
    int a=stoi(s);
    for(int i=0;i*i<=a;i++)
    {
        for(int j=0;j*j<=a;j++)
        {
            if((i+j)*(i+j)==a)
            {
                cout<<i<<" "<<j<<endl;
                return ;
            }
        }
    }
    cout<<-1<<endl;
}
signed main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int T=1;
    cin>>T;
    while(T--)
    {
       solve();
    }
    return 0;
}